package com.dkm.ec.relation.repository.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.dkm.base.core.helper.SpringHelper;
import com.dkm.base.db.persistence.dao.IQueryDao;
import com.dkm.biz.repository.AbstractRepository;
import com.dkm.ec.relation.domain.RelationFriend;
import com.dkm.ec.relation.repository.RelationFriendRepository;
import com.dkm.ou.me.persistence.entity.UserPo;
import com.dkm.ec.relation.persistence.dao.RelationFriendQueryDao;
import com.dkm.ec.relation.persistence.entity.RelationFriendPo;

/**
 * 对象功能:t_relation_friend Repository接口的实现类
 * 开发公司:dkm.com
 * 开发人员:ZHH
 * 创建时间:2017-07-22 10:16:37
 */
@Repository
public class RelationFriendRepositoryImpl extends AbstractRepository<String, RelationFriendPo,RelationFriend> implements RelationFriendRepository{
	  
	@Resource
	private  RelationFriendQueryDao relationFriendQueryDao;

	public RelationFriend newInstance() {
		RelationFriendPo po = new RelationFriendPo();
		RelationFriend relationFriend = SpringHelper.getBean(RelationFriend.class);
		relationFriend.setData(po);
		return relationFriend;
	}

	public RelationFriend newInstance(RelationFriendPo po) {
		RelationFriend relationFriend = SpringHelper.getBean(RelationFriend.class);
		relationFriend.setData(po);
		return relationFriend;
	} 
	
	@Override
	protected IQueryDao<String, RelationFriendPo> getQueryDao() {
		return relationFriendQueryDao;
	}

	@Override
	public List<RelationFriendPo> findByFriendById(String partyId, String requestPartyId) {
		Map<String, Object> params =new HashMap<String, Object>();
		params.put("partyId", partyId);
		params.put("requestPartyId", requestPartyId);
		return relationFriendQueryDao.findByKey("findByFriendById", params);
	}

	@Override
	public String findByFriendIds(List<String> phones) {
		Map<String, Object> params =new HashMap<String, Object>();
		params.put("phones", phones);
	    RelationFriendPo relationFriendPo =  relationFriendQueryDao.getByKey("findByFriendIds", params);
		return relationFriendPo.getFriendId();
	}
	
}
